package top.itczw.beetl.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.beetl.sql.core.TailBean;
import org.beetl.sql.core.orm.OrmCondition;
import org.beetl.sql.core.orm.OrmQuery;

import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * @author czw
 * @description: 一对一查询不需要sqlId也可以查询，一对多需要查询中间表，需要sqlId写sql
 */
@OrmQuery(
		value={
				//一对一
				@OrmCondition(target=Department.class,attr="departmentId",targetAttr="id",type=OrmQuery.Type.ONE),
				//一对多
				@OrmCondition(target=Role.class,attr="id",targetAttr="userId" ,sqlId="user.selectRole",type=OrmQuery.Type.MANY)
		}
)
public class User extends TailBean implements Serializable{
	private Integer id ;
	private Integer age ;

	private String name ;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	private Date createDate ;

	private List<Role> role;

	private Department department;
	
	public User() {

	}
	
	public Integer getId(){
		return  id;
	}
	public void setId(Integer id ){
		this.id = id;
	}
	
	public Integer getAge(){
		return  age;
	}
	public void setAge(Integer age ){
		this.age = age;
	}
	
	public String getName(){
		return  name;
	}
	public void setName(String name ){
		this.name = name;
	}
	
	public Date getCreateDate(){
		return  createDate;
	}
	public void setCreateDate(Date createDate ){
		this.createDate = createDate;
	}

	public List<Role> getRole() {
		return role;
	}

	public void setRole(List<Role> role) {
		this.role = role;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@Override
	public String toString() {
		return "User{" +
				"id=" + id +
				", age=" + age +
				", name='" + name + '\'' +
				", createDate=" + createDate +
				", department=" + department +
				'}';
	}
}
